package com.hopu.blb_erp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hopu.blb_erp.entity.PageEntity;
import com.hopu.blb_erp.entity.TMenu;
import com.hopu.blb_erp.entity.TWarning;
import com.hopu.blb_erp.mapper.TWarningMapper;
import com.hopu.blb_erp.service.TWarningService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class TWarningServiceImpl extends ServiceImpl<TWarningMapper, TWarning> implements TWarningService {
    @Autowired
    private TWarningMapper tWarningMapper;
    @Override
    public List<TWarning> selectAll() {
        return tWarningMapper.selectAll();
    }
    @Override
    public PageEntity<TWarning> findPage(Integer current, Integer length) {
        Integer count = tWarningMapper.selectCounts();
        List<TWarning> tWarnings = tWarningMapper.selectPages((current - 1) * length, length);
        PageEntity<TWarning> tMenuPageEntity = new PageEntity<>();
        tMenuPageEntity.setData(tWarnings);
        tMenuPageEntity.setCurrent(current);
        tMenuPageEntity.setCount(count);
        return tMenuPageEntity;
    }

    @Override
    public Integer selectCounts(String productId, String menuName) {
        return tWarningMapper.selectCount(productId,menuName);
    }

    @Override
    public PageEntity<TWarning> findPages(Integer current, Integer length, String productId, String menuName) {
        Integer count = tWarningMapper.selectCount(productId,menuName);
        List<TWarning> tWarnings = tWarningMapper.selectPage((current - 1) * length, length,productId,menuName);
        PageEntity<TWarning> tMenuPageEntity = new PageEntity<>();
        tMenuPageEntity.setData(tWarnings);
        tMenuPageEntity.setCurrent(current);
        tMenuPageEntity.setCount(count);
        return tMenuPageEntity;
    }

    @Override
    public List<TWarning> selectNum(String menuId) {
        return tWarningMapper.selectNum(menuId);
    }

    @Override
    public TWarning selectNums(String menuId) {
        return tWarningMapper.selectNums(menuId);
    }
}
